﻿<%@ Page Language="C#" MasterPageFile="~/admin.master" AutoEventWireup="true" Inherits="MediaMonitor.Admin.Data_Mgmt_Product"
    Theme="default" Title="Data Management - Products & their Versions" CodeBehind="data-mgmt-product.aspx.cs" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="Server">
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

        <script src="../rad-scripts/rad.js" type="text/javascript"></script>

    </telerik:RadCodeBlock>

    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Body" runat="Server">

    <div>
        Click the
        <img src="../App_Themes/default/cssimg/exapand.png" style="display: inline;" />
        link at the left side of records to expand the data.
        <br /><br />
    </div>
        
        <telerik:RadAjaxPanel ID="radPanel" runat="server" RestoreOriginalRenderDelegate="false">
        
        <telerik:RadGrid ID="radGrid" runat="server" AllowFilteringByColumn="True" AllowPaging="True"
            AllowSorting="True" GridLines="None" Skin="Hay" OnNeedDataSource="radGrid_NeedDataSource"
            Width="100%" AutoGenerateColumns="false" GroupingSettings-CaseSensitive="false"
            PageSize="20" OnDeleteCommand="radGrid_DeleteCommand">
            <MasterTableView DataKeyNames="ProductID" ExpandCollapseColumn-Groupable="true"
                ExpandCollapseColumn-GroupByExpression="ProductCode" GroupLoadMode="Client">
                <Columns>
                    <telerik:GridButtonColumn Text="Delete" ButtonType="LinkButton" ConfirmText="Are you sure to delete this record?" ConfirmTitle="Delete Confirmation" CommandName="Delete" />
                    <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="ProductCode" HeaderText="Product Code" />
                    <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="ProductName" HeaderText="Product Name" />
                    <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="LastModifiedDate" HeaderText="Last Modified" HtmlEncode="false"             
                        DataFormatString="{0:d}" /> 
                    <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="AgencyName" HeaderText="Agency Name" />                 
                    <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="SectorName" HeaderText="Sector" />
                    <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="SubSectorName" HeaderText="Sub Sector" />
                    <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="CategoryName" HeaderText="Category Name" />
                    <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="BrandName" HeaderText="Brand" />
                    <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="AdvertiserName" HeaderText="Advertiser Name " />
                    
                </Columns>
                
                <DetailTables>
                    <telerik:GridTableView AutoGenerateColumns="false" DataKeyNames="ProdVersionID" Caption="" AllowSorting="true"
                        PageSize="10" DataSourceID="sqlDS" AllowFilteringByColumn="false">
                        <ParentTableRelation>
                            <telerik:GridRelationFields MasterKeyField="ProductID" DetailKeyField="ProductID" />
                        </ParentTableRelation>
                        <ItemStyle CssClass="Level2AltItem" />
                        <AlternatingItemStyle CssClass="Level2AltItem" /> 
                        <Columns>
                            <telerik:GridButtonColumn Text="Delete" ButtonType="LinkButton" ConfirmText="Are you sure to delete this record? All versions of this product will also be deleted"  ConfirmTitle="Delete Confirmation" CommandName="Delete" />
                            <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="ProdVersionCode" HeaderText="Version Code" />
                            <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="ProdVersionName" HeaderText="Version Name" />
                            <telerik:GridTemplateColumn HeaderText="Preview">
                                <ItemTemplate>
                                    <a href="javascript:void(0);" onclick="PopupCenter('../sitefiles/video.aspx?pvid=<%#Eval("ProdVersionCode")%>&t=s', '_blank', 350, 280); ">
                                    <span style='color: <%# Utility.ToBool(Eval("ShortVideo"))==true ? "white" : "red"%>;'>
                                    <%#Utility.GetYesNo(Utility.ToBool(Eval("ShortVideo")))%>
                                    </span>
                                    </a>

                                    <span style='display: <%# Utility.ToBool(Eval("ShortVideo"))==true ? "inline" : "none"%>;'>
                                        <asp:LinkButton Visible="false" ID="lnkDelShortVideo" runat="server" OnClientClick="return confirm('Are you sure to delete the preview video file of this Product Version?')"
                                            OnClick="DelShortVideo" CommandArgument='<%#Eval("ProdVersionCode")%>'>[X]</asp:LinkButton>
                                    </span>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>

                            <telerik:GridTemplateColumn HeaderText="Full Video">
                                <ItemTemplate>
                                    <a href="javascript:void(0);" onclick="PopupCenter('../sitefiles/video.aspx?pvid=<%#Eval("ProdVersionCode")%>&t=f', '_blank', 350, 280); ">
                                        <span style='color: <%# Utility.ToBool(Eval("FullVideo")    )==true ? "white" : "red"%>;'>
                                            <%#Utility.GetYesNo(Utility.ToBool(Eval("FullVideo")))%>
                                        </span>
                                    </a>
                                    
                                    <span style='display: <%# Utility.ToBool(Eval("FullVideo"))==true ? "inline" : "none"%>;'>
                                        <asp:LinkButton Visible="false" ID="lnkDelFullVideo" runat="server" OnClientClick="return confirm('Are you sure to delete the full video file of this Product Version?')" OnClick="DelFullVideo" CommandArgument='<%#Eval("ProdVersionCode")%>'>[X]</asp:LinkButton>
                                    </span>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>

                            <telerik:GridBoundColumn  AutoPostBackOnFilter="true" DataField="DateModified" HeaderText="Last Modified" HtmlEncode="false"
                                DataFormatString="{0:d}" />
                        </Columns>
                    </telerik:GridTableView>
                </DetailTables>
            </MasterTableView>
            <ClientSettings>
                <Scrolling AllowScroll="false" />
                <ClientEvents OnFilterMenuShowing="filterMenuShowing" />
            </ClientSettings>
            <FilterMenu OnClientShowing="MenuShowing" />
             
        </telerik:RadGrid>
        
        <asp:LinkButton id="lnkHidden" runat="server" Text=""></asp:LinkButton>
        </telerik:RadAjaxPanel>
    
    <asp:SqlDataSource ID="sqlDS" runat="server" ConnectionString="<%$ ConnectionStrings:DBAdex %>"
        SelectCommand="SELECT * FROM ProdVersion WHERE ProductCode = @ProductCode">
        <SelectParameters>
            <asp:Parameter Name="ProductCode" DefaultValue="0" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>

